package cn.sonui.onlinechat.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.concurrent.atomic.AtomicReference;

@Controller
public class Room {
    @RequestMapping("/rooms")
    public String roomList(HttpServletRequest request){
        HttpSession session = request.getSession();
        AtomicReference<Boolean> isLogin = new AtomicReference<>((Boolean) session.getAttribute("login"));
        return Boolean.TRUE.equals(isLogin.get()) ? "rooms" : "redirect:login";
    }
}
